package com.cyt.web.controller.reward;

import cn.hutool.core.util.StrUtil;
import com.cyt.base.enums.BusinessType;
import com.cyt.base.enums.OperatorType;
import com.cyt.base.model.dto.ReturnResult;
import com.cyt.base.util.BaseConstant;
import com.cyt.reward.model.vo.RewardRecordVo;
import com.cyt.reward.service.RewardRecordService;
import com.cyt.reward.util.RewardDictCode;
import com.cyt.sys.aspect.BaseLog;
import com.cyt.web.controller.base.BaseController;
import com.cyt.wx.model.po.WxApply;
import com.cyt.wx.service.WxApplyService;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 打赏功能-打赏记录控制层
 *
 * @author rong yuan
 * @date 2019-7-24 13:44:54
 */
@RestController
public class RewardRecordController extends BaseController {

    @Resource
    private RewardRecordService rewardRecordService;

    /**
     * 统一跳转
     *
     * @param pageName 页面名称
     * @param applyId 应用id
     * @return ModelAndView
     * @author shengQiang Yu
     * @date 2019-08-28 15:17:40
     */
    @RequestMapping("/reward/rewardrecord/{pageName}")
    public ModelAndView goPage(@PathVariable("pageName") String pageName, String applyId) {
        ModelAndView view = new ModelAndView("/reward/rewardrecord/"+pageName);
        view.addObject("applyId",applyId);
        return view;
    }

    /**
     * 分页查询
     *
     * @param request        请求对象
     * @param rewardRecordVo 接受参数对象
     * @param page           当前页面
     * @param limit          页面数量
     * @return ReturnResult
     * @author rong yuan
     * @date 2019-7-24 13:44:54
     */
    @BaseLog(module = "打赏功能", classz = "打赏记录", methods = "分页查询对象", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/reward/rewardrecord/page", method = RequestMethod.POST)
    public ReturnResult page(HttpServletRequest request, RewardRecordVo rewardRecordVo, int page, int limit) {
        return rewardRecordService.page(rewardRecordVo, page, limit);
    }

    /**
     * 首页统计
     *
     * @param request        请求对象
     * @param rewardRecordVo 接受参数对象
     * @return ReturnResult
     * @author rong yuan
     * @date 2019-8-19 11:24
     */
    @BaseLog(module = "打赏功能", classz = "打赏记录", methods = "首页统计", businessType = BusinessType.GET, operatorType = OperatorType.MANAGE)
    @RequestMapping(value = "/reward/rewardrecord/statistics", method = RequestMethod.POST)
    public ReturnResult statistics(HttpServletRequest request, RewardRecordVo rewardRecordVo) {
        rewardRecordVo.setPayStatus(RewardDictCode.REWARD_PAY_STATUS_YZF);
        return new ReturnResult(rewardRecordService.statistics(rewardRecordVo));
    }
}